package com.personal.delete;

import com.personal.baseDao.DaoGenDB;
import java.lang.String;

public class DeleteDao extends DaoGenDB {
	
	/**
	 * 
	 * @param input 输入的时间 单位为 天数 day
	 * @param sqlType 选择执行的SQL <br>
	 * 0------>table:cas_service_ticket<br>
	 * 1------>table:cas_ticket_granting_ticket<br>
	 * 2----->table:ws_log
	 * @return 返回成功删除的数量
	 */
	public int delete(int input,int sqlType) {
		int count = 0;
		String sql ="";
		if(sqlType == 0){
		sql = "delete from cas_service_ticket cst where cst.creation_time <"
				+ " ((sysdate - "+input+" - to_date('1970-01-01','yyyy-mm-dd')) * 86400000)";
		}else if(sqlType == 1){
		sql = "delete from cas_ticket_granting_ticket ctgt where ctgt.creation_time < "
				+ "((sysdate - "+input+" - to_date('1970-01-01','yyyy-mm-dd')) * 86400000)";
		}else if (sqlType == 2){
		//删除ws_log表的数据
		sql = "delete from ws_log wsl where wsl.create_time < sysdate - "+input;
		}else{
			return 0;
		}
		count = super.deleteBySql(sql);
		return count;
	}
}
